﻿using System;
using System.Data;
using System.Collections.Generic;
using FiberRMS.Model.AlarmManager;
namespace FiberRMS.BLL.AlarmManager
{
    /// <summary>
    /// 业务逻辑类ALARM_INFO 的摘要说明。
    /// </summary>
    public class ALARM_INFO
    {
        private readonly FiberRMS.DAL.AlarmManager.ALARM_INFO dal = new FiberRMS.DAL.AlarmManager.ALARM_INFO();
        public ALARM_INFO()
        { }
        #region  成员方法
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(string ALARMNUMBER)
        {
            return dal.Exists(ALARMNUMBER);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(FiberRMS.Model.AlarmManager.ALARM_INFO model)
        {
            dal.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(FiberRMS.Model.AlarmManager.ALARM_INFO model)
        {
            dal.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public void Delete(string ALARMNUMBER)
        {

            dal.Delete(ALARMNUMBER);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public FiberRMS.Model.AlarmManager.ALARM_INFO GetModel(string ALARMNUMBER)
        {

            return dal.GetModel(ALARMNUMBER);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetListByObject(string strWhere)
        {
            return dal.GetListByObject(strWhere);
        }
        public DataSet GetAlarmTop50(string where)
        {
            return dal.GetAlarmTop50(where);
        }
        public string getAlarmObjectFromResive(string alarmobject)
        {
            return dal.getAlarmObjectFromResive(alarmobject);
        }
        /// <summary>
        /// 获取告警等级统计数据
        /// </summary>
        public DataSet GetAlarmLevelCount()
        {
            return dal.GetAlarmLevelCount();
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<FiberRMS.Model.AlarmManager.ALARM_INFO> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            List<FiberRMS.Model.AlarmManager.ALARM_INFO> modelList = new List<FiberRMS.Model.AlarmManager.ALARM_INFO>();
            int rowsCount = ds.Tables[0].Rows.Count;
            if (rowsCount > 0)
            {
                FiberRMS.Model.AlarmManager.ALARM_INFO model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new FiberRMS.Model.AlarmManager.ALARM_INFO();
                    model.ALARMNUMBER = ds.Tables[0].Rows[n]["ALARMNUMBER"].ToString();
                    if (ds.Tables[0].Rows[n]["ENDTIME"].ToString() != "")
                    {
                        model.ENDTIME = DateTime.Parse(ds.Tables[0].Rows[n]["ENDTIME"].ToString());
                    }
                    model.ISCLEARED = ds.Tables[0].Rows[n]["ISCLEARED"].ToString();
                    model.CLEARPERSON = ds.Tables[0].Rows[n]["CLEARPERSON"].ToString();
                    model.ALARMEXPLAIN = ds.Tables[0].Rows[n]["ALARMEXPLAIN"].ToString();
                    model.BELONGEQUIP = ds.Tables[0].Rows[n]["BELONGEQUIP"].ToString();
                    model.BELONGTRANSYS = ds.Tables[0].Rows[n]["BELONGTRANSYS"].ToString();
                    model.BELONGSTATION = ds.Tables[0].Rows[n]["BELONGSTATION"].ToString();
                    if (ds.Tables[0].Rows[n]["RECORDDATE"].ToString() != "")
                    {
                        model.RECORDDATE = DateTime.Parse(ds.Tables[0].Rows[n]["RECORDDATE"].ToString());
                    }
                    model.ALARMDESC = ds.Tables[0].Rows[n]["ALARMDESC"].ToString();
                    model.PRIMALCAUSE = ds.Tables[0].Rows[n]["PRIMALCAUSE"].ToString();
                    model.ALARMOBJECT = ds.Tables[0].Rows[n]["ALARMOBJECT"].ToString();
                    model.TRANTYPE = ds.Tables[0].Rows[n]["TRANTYPE"].ToString();
                    model.VENDOR = ds.Tables[0].Rows[n]["VENDOR"].ToString();
                    model.BELONGDOMAIN = ds.Tables[0].Rows[n]["BELONGDOMAIN"].ToString();
                    model.EQUIPMODEL = ds.Tables[0].Rows[n]["EQUIPMODEL"].ToString();
                    model.PACKTYPE = ds.Tables[0].Rows[n]["PACKTYPE"].ToString();
                    model.PREEQUIP = ds.Tables[0].Rows[n]["PREEQUIP"].ToString();
                    model.PRESTATION = ds.Tables[0].Rows[n]["PRESTATION"].ToString();
                    model.DEDUSEFAULT = ds.Tables[0].Rows[n]["DEDUSEFAULT"].ToString();
                    model.PERSISTTIME = ds.Tables[0].Rows[n]["PERSISTTIME"].ToString();
                    model.ISSYNC = ds.Tables[0].Rows[n]["ISSYNC"].ToString();
                    model.OBJECTCODE = ds.Tables[0].Rows[n]["OBJECTCODE"].ToString();
                    model.OBJCLASS = ds.Tables[0].Rows[n]["OBJCLASS"].ToString();
                    model.ALARMTYPE = ds.Tables[0].Rows[n]["ALARMTYPE"].ToString();
                    model.PROBABLECAUSE = ds.Tables[0].Rows[n]["PROBABLECAUSE"].ToString();
                    model.ALARMTEXT = ds.Tables[0].Rows[n]["ALARMTEXT"].ToString();
                    model.ALARMLEVEL = ds.Tables[0].Rows[n]["ALARMLEVEL"].ToString();
                    model.ISTICKET = ds.Tables[0].Rows[n]["ISTICKET"].ToString();
                    if (ds.Tables[0].Rows[n]["STARTTIME"].ToString() != "")
                    {
                        model.STARTTIME = DateTime.Parse(ds.Tables[0].Rows[n]["STARTTIME"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }
        /// <summary>
        /// 获得统计告警的详细数据
        /// </summary>
        /// <param name="whereStr"></param>
        /// <returns></returns>
        public DataSet GetStatisticAlarm(string whereStr)
        {
            return dal.GetStatisticAlarm(whereStr);
        }
         /// <summary>
        /// 调用存储过程获取对象告警,如果对象存在下级对象,则同时获取其下级对象的告警
        /// </summary>
        /// <param name="OBJECTID">对象ID</param>
        /// <param name="OBJECTTYPE">对象类型</param>
        /// <param name="OBJECTTEXT">对象文本</param>
        /// <returns></returns>
        public DataSet GetEquipAlarm(string OBJECTID, string OBJECTTYPE,string OBJECTTEXT)
        {
            return dal.GetEquipAlarm(OBJECTID, OBJECTTYPE, OBJECTTEXT);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        //public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        //{
        //return dal.GetList(PageSize,PageIndex,strWhere);
        //}

        #endregion  成员方法
    }
}

